<?php
require('includes/top.php');
$vphone=$_POST['vphcode'].'-'.$_POST['vphone'];
$vmobile=$_POST['vmobstdCode'].'-'.$_POST['vmobile'];
$vusername = $_POST["vusername"];
$vpwd = $_POST["vpwd"];
$vcompanyName = $_POST["vcompanyName"];				
$vcompanyAdd = $_POST["vcompanyAdd"];
$vwebsiteName=$_POST['vwebsiteName'];
$vprodDealing=$_POST['vprodDealing'];
$vcomClientsServed=$_POST['vcomClientsServed'];
$vUps=$_POST['vUps'];
$vcomOwnersExprenc=$_POST['vcomOwnersExprenc'];
$awardsAccolade=$_POST['awardsAccolade'];
$vsubcategory = $_POST["vsubcategory"];
$vcategory = $_POST["vcategory"];				
$compInfo=$_POST['compInfo'];
$vPersonInCharge=$_POST['vPersonInCharge'];
$country_id=$_POST['country_id'];
$vendors_res_no=$_POST['vresphcode'].'-'.$_POST['vendors_res_no'];
$category = $_POST['category'];



$sql = "INSERT INTO vendors (`vendors_phone`, `vendors_mob`, `vendors_username`, `password`, `company_name`, `company_address`, `website_name`, `product_dealing`, `companies_clients_served`, `companys_USP`, `company_owners_experience`, `awards_accolade`, `subcategory_id`,  `vendor_cat_id`, `company_info`, `person_in_charge_owner`,`country_id`, `vendors_res_no`,`vendor_category_id`) VALUES ('$vphone', '$vmobile', '$vusername', '$vpwd', '$vcompanyName', '$vcompanyAdd', '$vwebsiteName', '$vprodDealing', '$vcomClientsServed', '$vUps', '$vcomOwnersExprenc', '$awardsAccolade','$vsubcategory','$vcategory', '$compInfo','$vPersonInCharge', '$country_id', '$vendors_res_no','$category')";


$result=mysql_query($sql);
 if($result)
 {
		$userid = mysql_query("select * from vendors where vendors_username='".$vusername."'");
		$getUserId = mysql_fetch_array($userid);
			$uid = $getUserId['vendors_id'];
			echo $uid;

	 foreach($_POST['vcheck'] as $a)
	 {
		 echo $a;
		 $sql1 = "INSERT INTO location (`location`, `user_id`, `user_type`) VALUES ('$a', '$uid', 'Vendor')";
		 $result=mysql_query($sql1);
	 }
header("location:add_vendor.php");
}
 else
 {
	 echo mysql_error();
 }
ob_flush();
?>
 